home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 24 / Commodore_Free_Issue_24_2008_Commodore_Computer_Club.d64 / t.b guide 9.1 < prev    next >
Text File  |  2023-02-26  |  12KB  |  384 lines

  1. u
  2. In the Beginning Chaper 9, Section 1
  3. Lord Ronin from Q-Link
  4.  
  5.  Back again and into those pesky pokes
  6. and peeks. We did do some of that
  7. already, when we typed poke53280,x
  8. where x is a number between 0-15, this
  9. command Changed the colour of the
  10. screen border. That is a poke, and one
  11. of the first ones you learn. Now I
  12. know that it looks like there are at
  13. the least 53,280 poke places when you
  14. look at the number. Besides what does
  15. each one of them do exactly? Well
  16. those are two questions that I as a
  17. beginner have asked, and not yet found
  18. the book(s) to answer them.
  19.  
  20.  Keeping that in mind, lets not let
  21. the lack of information dampen our
  22. spirits. Take it as there is a lot one
  23. can learn about the C=. Our next
  24. programme may bum you out when you run
  25. it, I know it did that to me the first
  26. few times I entered it. I will explain
  27. the what and why afterwards just type
  28. in this program as shown.
  29.  
  30. new
  31.  
  32. 10 forba=0to15
  33. 20 forbo=0to15
  34. 30 poke53280,ba
  35. 40 poke53281,bo
  36. 50 forx=1to2000:nextx
  37. 60 nextbo:nextba
  38.  
  39.  Run this and you will have the screen
  40. and border change colour, you may
  41. think you entered the programme
  42. listing incorrectly, the screen
  43. changes colour. But what about the
  44. border colour as it Seems to stay the
  45. same. That is what many of the members
  46. of the user group thought over the
  47. years. To tell the truth so did I for
  48. a time, that is until I tried to tear
  49. apart the programme and find out what
  50. was happening. To save you the
  51. frustration it is in line 60, you need
  52. to read that line a few times
  53. remembering how the next command works
  54. in a for next loop. Have you seen it
  55. yet? 
  56.  
  57. Well I didn't for a time. What happens
  58. here is that the for that comes first
  59. that is the one for the BA variable,
  60. will do its thing starting at line 10.
  61. OK got that part. Now see line 60 here
  62. BA is going to do its thing until the
  63. set amount, then go back in 10 with
  64. the 0 to15 part. Right the screen
  65. changes 16 times before the border
  66. will change or the other way round,
  67. depending what you put in first. I did
  68. it both ways. In line 10 and in line
  69. 60. Mess with the placement of the BA
  70. & BO variable and you will see what I
  71. mean.
  72.  
  73. I think We have played enough with the
  74. FOR NEXT loop to catch most of the
  75. lines in some form. Line 50 is the
  76. delay. Right I know your question now.
  77. "2000 what?" for the delay. Can't tell
  78. you for rock certain, but I have been
  79. told by most people that it is a
  80. "jiffy"; No that isn't a silly term.
  81. Actually it is a unit of measurement
  82. for time, here a jiffy is 1/60th of a
  83. second. PAL users have a different one
  84. or so I have been told. Simple
  85. electronics here. Current/Voltage what
  86. ever term works best for you. Changes
  87. from a + to a - <seen on an
  88. oscciloscope> 60 times a second. This
  89. is called the line frequency and is
  90. used a lot in crystals in circuits,
  91. for timing and other things I have
  92. long forgotten. OK that is more than
  93. enough on that part. Just want you to
  94. see the relationship there with the
  95. jiffy being 1/60th of a second. Unless
  96. what I was told was wrong.
  97.  
  98.  With a little experimenting you can
  99. shorten those lines down and make the
  100. programme run faster. You can also fix
  101. it to have the border and the screen
  102. flash at about the same time. Probably
  103. you can guess that to make it run
  104. faster, all you need to do is change
  105. that delay in line 50. Now how to make
  106. both border and screen flash at the
  107. same time? Not gonna tell ya <EG> But
  108. I'll give you some hints. Make just
  109. one FOR variable for the value 0 to
  110. 15. Put the two poke codes on the same
  111. line with the : symbol between them
  112. and use the same variable. I'll let
  113. you play around with this and see what
  114. you can make.
  115.  
  116.  All Right! Been bugged enough to drop
  117. back a session and tell you how to
  118. find those 8 other colours for that
  119. colour bar. Simply use the command
  120. PRINTASC("X"). X here will be you
  121. typing in the C= key and one of the
  122. number keys. Press return and it will
  123. tell you the code number. That is what
  124. you use for the rest of the lines in
  125. that colour bar programme. User Group
  126. members and Girl Friends can be such a
  127. pain in the Tucus. <G>
  128.  
  129.  Back to that programme. Add the
  130. following line.
  131.  
  132. 25 ?chr$(147);"border
  133. =";peek(53280)and15, "background =
  134. ";peek(53281)and15
  135.  
  136. Fits on about 1.8 lines of your
  137. screen, shorter if you use more
  138. shortcut codes. What happens here is
  139. the screen clears and at the top will
  140. be the words "border and background".
  141. Then after the = symbol, you will see
  142. the colour number from 0 to 15 for
  143. each one (border or screen). Tip, if
  144. you play with this programme and have
  145. short end it up a bit. Make certain to
  146. have this programme line happen after
  147. the poke codes. If not you stand a
  148. chance of being one number off, this
  149. happened to the students and to me in
  150. the process of our learning.
  151.  
  152.  Now we enter a new bit and this one
  153. is more complicated. Personally I
  154. think its made to have you ask more
  155. questions than it gives, while trying
  156. to make you more interested in
  157. programming. This trick may have
  158. worked in the 80s. These days, the
  159. lack of in depth information, has
  160. turned some people off. Being
  161. frustrated with no more information.
  162. You may see what I mean at this point.
  163.  
  164. Screen Graphics, doesn't mean what you
  165. may expect it to mean, at least at
  166. this level. Remember this is from the
  167. users book that came with the C=64,
  168. short and allegedly simple, only three
  169. short paragraphs. The book talks about
  170. how we have placed characters on the
  171. screen using the PRINT command, all
  172. printing has been sequential. The book
  173. speaks about moving to a specific spot
  174. on the screen using print and cursor
  175. commands. We haven't done that much.
  176. Oh we did do that one to make the
  177. bouncing ball go down a certain number
  178. of lines. Most people at the beginning
  179. level of programming, like me, use
  180. cursor commands to move to a specific
  181. point on the screen. I have copied
  182. type in books that do the same thing.
  183.  
  184.  What that would look like in a type
  185. in book would be something on the
  186. lines of PRINT"(cursor down 10)";
  187. "(cursor right 5)". Taking the
  188. starting point of what you are doing
  189. down 10 rows and over 5 columns. What
  190. you type in the computer would be 10
  191. times pressing the cursor down key.
  192. Getting the symbol on the screen each
  193. time. Then 5 presses of the right
  194. cursor key, also getting the right
  195. symbol on screen. Right there we have
  196. 15 key strokes on a programming line.
  197. There has got to be a better way? I
  198. mean this is long and takes up
  199. programming space. The book says just
  200. about the same thing.
  201.  
  202.  All is not lost; there are locations
  203. in the computer memory to control
  204. locations where to place text on
  205. screen. Just as there is for colour
  206. work.
  207.  
  208. There are 1000 areas on the screen, A
  209. screen is 40 columns across by 25 rows
  210. down. I can't make the little grid map
  211. here for you in text but suffice to
  212. say that it is 40 wide and 25 tall;
  213. making 1000 squares in total on the
  214. grid. Graph paper and lining this out
  215. may be of a help to you as a visual
  216. aid. OK here is something that you may
  217. be shocked about. Each one of these
  218. 1000 locations can hold a number, a
  219. number between the value of 0 and 255.
  220. Yeah that means you have a choice of
  221. 256 numbers for each of the 1000 grid
  222. areas on the screen, it all becomes a
  223. bit mind boggling at this point. <G>
  224.  
  225.  The way to place things on screen at
  226. this at this stage is with the good
  227. old POKE command. Putting the number
  228. for what ever you decided upon, onto a
  229. specific area of the screen.
  230.  
  231.  However we have to now deal with some
  232. new numbers. These numbers are the
  233. Screen Memory Map. Being the locations
  234. on the screen to poke things into and
  235. therefore onto the screen. Top left
  236. corner. Being row 0 and column 0 is
  237. location 1024, the bottom row last
  238. column, Or the bottom right end of the
  239. screen is location 2023. Now you can
  240. use the grid map and mark out the
  241. rows. Ah row 0 is 1024 row 24 <the
  242. last row, or 25 if you counted
  243. starting with 1 instead of 0> Starts
  244. out at 1984. Column 0 is the top left.
  245. Top right is column 39. For those that
  246. want to make their own grid chart. I
  247. did this because the one in the book
  248. is too small for my ancient eyes. <G>
  249.  
  250.  Well of course you can count the grid
  251. squares and find the right screen
  252. memory location, or you could be lazy
  253. and use a simple formula. I'm lazy
  254. these days.
  255.  
  256.  POINT =1024 + X + 40*Y
  257.  
  258.  Freaky right? OK it was for me the
  259. first several times that I went
  260. through this part of the book. Didn't
  261. have anyone to talk me through the
  262. entire book.
  263.  
  264. Tearing this apart from the beginning.
  265. POINT simply means the location on the
  266. screen for what you are putting there,
  267. <gotta work on the grammar>. End
  268. result is going to be a number between
  269. the 1024 start and the 2023 end, block
  270. of numbers. Being the place to insert,
  271. what ever it is you are inserting.
  272. Yeah that was worded better. <G>
  273.  
  274.  1024 is the start number, being the
  275. one that is at the top left of the
  276. grid. Makes that the base number to
  277. add the rest of the stuff to for the
  278. location.
  279.  
  280.  X is the column, lets use the one
  281. from the book, they give 20 for the
  282. column.
  283.  
  284.  Y is the row, and from the book that
  285. is 12.
  286.  
  287.  Formula would then read...
  288.  
  289. POINT = 1024 + 20 + 40*12
  290.  
  291.  OK the book doesn't do that stage and
  292. that did throw off several of my
  293. members over the years. Putting it in
  294. here to keep things linear. This would
  295. then read...
  296.  
  297. POINT = 1024 +20 + 480
  298.  
  299.  Finally POINT = 1524, that is the
  300. point on the screen at the junction of
  301. column 20 and row 12. As listed for
  302. the Screen Memory Map.
  303.  
  304.  Catch your breath after that bit, we
  305. have some more to do, and it isn't in
  306. my opinion giving enough time to go
  307. trough the above.
  308.  
  309.  Next thing the book wants you to do
  310. is type in ...
  311.  
  312. poke 1524,81
  313. poke 55796,1
  314.  
  315.  Got the idea that poke is putting
  316. something into the computer memory
  317. location. From that previous formula
  318. You can see that the 1524 is the
  319. answer to that formula above with the
  320. column of 20 and the row of 12. Guess
  321. you have seen enough of the previous
  322. sections to see that the 81 thing is
  323. what is going into that 1524 area.
  324.  
  325. 55796 is a new thing that is sprung on
  326. you. Sure you know that the 1 thing is
  327. what is going in that area. What is
  328. 55796? Out of the range of the Screen
  329. Memory Map so can't be a location, in
  330. that range.
  331.  
  332.  Saying that you haven't typed that
  333. stuff in as of yet. So you aren't
  334. aware of what the screen does, when
  335. this is completed. I want to point out
  336. that from the colour work we have done
  337. for the screen and the background poke
  338. codes. That you might see the number
  339. above as being close to the poke codes
  340. for the colour location of the border
  341. and screen.
  342.  
  343.  That isn't correct, but it is close.
  344. The next section of the book is on the
  345. COLOUR MEMORY MAP. They just have you
  346. type the above in to place a ball.
  347. Which is the 81 code and is also the
  348. shifted Q. Why they have you type the
  349. stuff in, will have the ball show up
  350. in close to the centre of the screen.
  351. The next poke will turn that to a
  352. white ball. If that didn't happen
  353. check your type work, see if you are
  354. in the upper case, if the symbol isn't
  355. right. If the colour didn't change,
  356. first thing is to check is if you
  357. typed everything right. Yeah I say
  358. that a lot and am guilty of that in my
  359. typing in of programmes, and more
  360. times than I want to admit. But if it
  361. is correct and the ball didn't change
  362. to white, don't fret, where you in
  363. white text colour in the first place?
  364. I mean was that the last colour that
  365. you were using on the screen? Sounds
  366. silly, but it has happened in the
  367. group.
  368.  
  369.  Change that 1 to a 2 in the poke that
  370. did the colour. Right the 55796,1
  371. becomes a 55796,2. now the ball
  372. changes to red. Play around a bit with
  373. the colours and with the symbols. Try
  374. different numbers. Changing that ,81
  375. to what ever you like from 0-255. Some
  376. will work as one of the symbols. 32
  377. and 96 are the space command. Right
  378. the one for the spacebar. Oh yeah feel
  379. free, all you space fans to make jokes
  380. about the space BAR. [VBG]
  381.  
  382.           CONTINUED IN SECTION 2
  383.  
  384.